package com.tiantianyuegou.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tiantianyuegou.R;
import com.tiantianyuegou.model.GoodsModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by George on 2016/9/9.
 */
public class ColorAndSizeAdapter extends BaseAdapter {
    private Context context;
    private List<GoodsModel> data;


    public ColorAndSizeAdapter(Context context) {
        this.context = context;
        data=new ArrayList<>();
    }

    public ColorAndSizeAdapter(Context context, List<GoodsModel> data) {
        this.context = context;
        this.data = data;
    }
    public void setData(List<GoodsModel> data){
        this.data.clear();
        this.data.addAll(data);
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh;
        if (convertView==null){
            convertView = View.inflate(context, R.layout.grid_item_color_size, null);
            vh = new ViewHolder();
            vh.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
            convertView.setTag(vh);

        }else{
            vh = (ViewHolder) convertView.getTag();

        }
//        vh.tv_content.setText(data.get(position).);
        return convertView;
    }
    class ViewHolder{
        TextView tv_content;
    }
}
